package com.example.demo2.demos.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {
    // http://127.0.0.1:8080/test?name=name&pwd=pwd

    @RequestMapping("/test")
    @ResponseBody
    public  String test(@RequestParam(name = "name",
            defaultValue = "unknown")String name,
            @RequestParam(name="pwd",defaultValue = "123")String pwd){
        return "test"+name+pwd;
    }
    // restful
    // http://127.0.0.1:8080/test01/name
    @RequestMapping("/test01/{name}")
    @ResponseBody
    public String hello(@PathVariable("name")String name){
        return "hello"+name;
    }
    // http://127.0.0.1:8080/topage
    @RequestMapping("/topage")
    public String topage(){
        return "aaa/index.html";
    }
}
